<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 构造函数中的this -> 构造函数在执行过程中 创建的实例化对象

    function Dog(name, color) {
        // {}
        // this -> {}

        this.name = name;
        this.color = color;

        // this[[prototype]] = Dog.prototype;  // this.__proto__ = Dog.prototype
        // return this;
    }

    // prototype 
    // Dog.prototype.constructor = Dog;
    Dog.prototype.species = "狗";
    Dog.prototype.say = function () {
        // this -> 调用此方法的实例化对象
        console.log(this.name, this.color);
    };

    console.dir(Dog);

    var d1 = new Dog("旺财", "黑色");
    // console.log(d1);
    // console.log(d1.constructor);

    d1.say();  // this -> d1

    Dog.prototype.say();  // this ->  Dog.prototype


    // var fn = function () { }
    // console.dir(fn);


</script>

</html>